﻿using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Networking;

public class GameMode : Entity
{
    protected override void Awake()
    {
        base.Awake();
        if (Instance != null)
        {
            object[] args = new object[] { base.GetType() };
            Debug.LogErrorFormat("Multi '{0}' is not allowed", args);
            base.enabled = false;
        }
        else
        {
            Instance = this;
        }
    }

    protected virtual void OnAnyLifeDieOrDestroy(Life life)
    {
    }

    protected virtual void OnAnyLifeResurrect(Life life)
    {
    }

    protected virtual void OnCombat(Combat combat)
    {
    }

    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        base.OnDeserialize(reader, initialState);
    }

    protected override void OnDestroy()
    {
        base.OnDestroy();
        if (Instance == this)
        {
            Instance = null;
        }
    }

    protected override void OnDisable()
    {
        base.OnDisable();
        Life.onAnyDie -= new Action<Life>(this.OnAnyLifeDieOrDestroy);
        Life.onAnyDestroy -= new Action<Life>(this.OnAnyLifeDieOrDestroy);
        Life.onAnyResurrect -= new Action<Life>(this.OnAnyLifeResurrect);
        Combat.onAnyCreate -= new Action<Combat>(this.OnCombat);
    }

    protected override void OnEnable()
    {
        base.OnEnable();
        Life.onAnyDie += new Action<Life>(this.OnAnyLifeDieOrDestroy);
        Life.onAnyDestroy += new Action<Life>(this.OnAnyLifeDieOrDestroy);
        Life.onAnyResurrect += new Action<Life>(this.OnAnyLifeResurrect);
        Combat.onAnyCreate += new Action<Combat>(this.OnCombat);
    }

    public override bool OnSerialize(NetworkWriter writer, bool forceAll)
    {
        bool flag;
        bool flag2 = base.OnSerialize(writer, forceAll);
        return (flag | flag2);
    }

    public virtual void OverGame()
    {
        this.isGameOver = true;
    }

    public virtual void ReloadGame()
    {
        IngameScene.Reload();
    }

    private void UNetVersion()
    {
    }

    public static GameMode Instance
    {
        [CompilerGenerated]
        get
        {
            return <Instance>k__BackingField;
        }
        [CompilerGenerated]
        private set
        {
            <Instance>k__BackingField = value;
        }
    }

    public bool isGameOver { get; private set; }
}

